<?php
include('../include/db-connect.php');
$getCat = $_GET["cat"];
$getType = $_GET["type"];
$getTitle = $_GET["title"];
//Type, Category, Title, Filename
if(!isset($getType,$getTitle,$getCat))
{
	subGetType();
}

function subGetType()
{
	$data = array();
	$sql = mysql_query("SELECT type FROM media GROUP BY type ORDER BY type DESC");
	while ($row = mysql_fetch_array($sql))
	{
		$type = $row['type'];
		array_push($data, $type);
	}//End while
echo json_encode($data);
}//End subGetType
function subGetCat()
{
	$data = array();
	$type = addslashes($type);
	$sql = mysql_query("SELECT category FROM media WHERE type LIKE '$type' GROUP BY category ORDER BY category DESC");
	while ($row = mysql_fetch_array($sql))
	{
		$category = $row['category'];
		array_push($date,$type);
	}//End while
echo json_encode($data);
}//End subGetCat
function subGetTitle()
{
	$data = array();
	$category = addslashes($category);
	$type = addslashes($type);
	$sql = mysql_query("SELECT title FROM media WHERE type LIKE '$type' AND category LIKE '$category' GROUP BY title ORDER BY title DESC");
	while( $row = mysql_fetch_array($sql))
	{
		$title = $row['title'];
		array_push($data,$title);
	}//End While 
echo json_encode($data);
}//End subGetTitle
function subGetFile()
{
	$data = array();
	$type = addslashes($type);
	$category = addslashes($category);
	$title = addslashes($title);
	$sql = mysql_query("SELECT filename FROM media WHERE type LIKE '$type' AND category LIKE '$category' AND title LIKE '$title' ORDER BY filename DESC");
	while( $row = mysql_fetch_array($sql))
	{
		$filename = $row['filename'];
		array_push($data,$filename);
	}//End while
echo json_encode($data);
}//End subGetFile


?>
